﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Globalization;

namespace _19.Exercise
{
    class Program
    {
        static void Main(string[] args)
        {
            string text = "Write a program that extracts from 25.19.2006 a given text all dates that 24.07.2008 match the format";
            MatchCollection dates = Regex.Matches(text, @"[0-3][0-9]\.[0-1][0-9]\.\d{4}");
            DateTime date;
            foreach (Match item in dates)
            {
                if (DateTime.TryParseExact(item.Value, "dd.MM.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
                {
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA");
                    Console.WriteLine(date.ToShortDateString());                    
                }
            }
        }
        //DateTime.TryParseExact(item.Value, "dd.MM.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
        //        Console.WriteLine(date.ToString(CultureInfo.GetCultureInfo("en-CA").DateTimeFormat.ShortDatePattern));

    }
}
